<template>
  <div class="main">
    <div id="sangshentu"></div>
  </div>
</template>
<script>
import * as echarts from "echarts";
export default {
  mounted() {
    this.sangshentu();
  },
  methods: {
    sangshentu: () => {
      const dom = document.querySelector("#sangshentu");
      echarts.init(dom).setOption({
        title: {
          text: "Funnel",
          left: "left",
          top: "bottom",
        },
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b} : {c}%",
        },
        toolbox: {
          orient: "vertical",
          top: "center",
          feature: {
            dataView: { readOnly: false },
            restore: {},
            saveAsImage: {},
          },
        },
        legend: {
          orient: "vertical",
          left: "left",
          data: ["Show", "Click", "Visit", "Inquiry", "Order"],
        },
        series: [
          {
            name: "Funnel",
            type: "funnel",
            width: "40%",
            height: "45%",
            left: "5%",
            top: "50%",
            data: [
              { value: 60, name: "Visit" },
              { value: 30, name: "Inquiry" },
              { value: 10, name: "Order" },
              { value: 80, name: "Click" },
              { value: 100, name: "Show" },
            ],
          },
          {
            name: "Pyramid",
            type: "funnel",
            width: "40%",
            height: "45%",
            left: "5%",
            top: "5%",
            sort: "ascending",
            data: [
              { value: 60, name: "Visit" },
              { value: 30, name: "Inquiry" },
              { value: 10, name: "Order" },
              { value: 80, name: "Click" },
              { value: 100, name: "Show" },
            ],
          },
          {
            name: "Funnel",
            type: "funnel",
            width: "40%",
            height: "45%",
            left: "55%",
            top: "5%",
            label: {
              position: "left",
            },
            data: [
              { value: 60, name: "Visit" },
              { value: 30, name: "Inquiry" },
              { value: 10, name: "Order" },
              { value: 80, name: "Click" },
              { value: 100, name: "Show" },
            ],
          },
          {
            name: "Pyramid",
            type: "funnel",
            width: "40%",
            height: "45%",
            left: "55%",
            top: "50%",
            sort: "ascending",
            label: {
              position: "left",
            },
            data: [
              { value: 60, name: "Visit" },
              { value: 30, name: "Inquiry" },
              { value: 10, name: "Order" },
              { value: 80, name: "Click" },
              { value: 100, name: "Show" },
            ],
          },
        ],
      });
    },
  },
};
</script>
<style lang="less" scoped>
.main {
  display: grid; // 声明一个容器
  grid-template-columns: repeat(3, 1fr); //分成三栏，每栏均等分
  grid-gap: 10px 20px; //行间距 列间距

  div {
    width: 1500px;
    height: 500px;
  }
}
</style>
